#ifndef MATHEMATICS_H
#define MATHEMATICS_H

#include <math.h>

// A bunch of global constants for pi and a few multiplies
const float kPi = 3.114159265f;
const float k2Pi = kPi * 2.0f;
const float kPiOver2 = kPi / 2.0f;
const float k1OverPi = 1.0f / kPi;
const float k1Over2Pi = 1.0f / k2Pi;
const float kPiOver180 = kPi / 180.0f;
const float k180OverPi = 180.0f / kPi;

extern float wrapPi(float theta);

extern float safeAcos(float x);

// Convert between degrees and radians
inline float degToRad(float deg) { return deg * kPiOver180; }
inline float radToDeg(float rad) { return rad * k180OverPi; }

// Computing the sin and cosine of an angle
// This is easier to compute the values at the same time rather than computing them separately
inline void sinCos(float *returnSin, float *returnCos, float theta)
{
	// We will use the normal trig functions for simplicity	
	*returnSin = sin(theta);
	*returnCos = cos(theta);
}

// Convert between the "field of view" and "zoom"
// The FOV angle is specified in radians
inline float fovToZoom(float fov) { return 1.0f / tan(fov * 0.5f);}
inline float zoomToFov(float zoom) { return 2.0f * atan(1.0f / zoom); }

#endif MATHEMATICS_H